package com.aaa.controller.front;

import com.aaa.entity.*;
import com.aaa.service.front.ZMRICategoryService;
import com.aaa.service.front.ZMRIGoodsService;
import com.aaa.service.front.ZMRISpecificationService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/front")
@Controller
public class SearchResultController {

    @Resource
    private ZMRIGoodsService zmriGoodsService;
    @Resource
    private ZMRICategoryService zmrCategoryService;
    @Resource
    private ZMRISpecificationService specificationService;

    @RequestMapping("/search-result")
    public String searchresult(Integer categoryId, Model model, GoodsQuery goodsQuery, Integer curPage, Integer pageSize){
        //查询商品数据
        curPage =curPage==null?1:curPage;
        PagerData<Goods> pd=zmriGoodsService.list(categoryId,goodsQuery,curPage,3);
        //查询分类数据
        List<Category> categoryList=zmrCategoryService.LIST();
        //查询商品规格数据
        List<Specification> specificationList=specificationService.LIST();
        model.addAttribute("pd",pd);
        model.addAttribute("categoryList",categoryList);
        model.addAttribute("specificationList",specificationList);
        return "/front/search-result";
    }
}
